//
//  UIImage+color.m
//  xiaobaima
//
//  Created by xbmios on 2017/11/28.
//  Copyright © 2017年 xbmios. All rights reserved.
//

#import "UIImage+color.h"

@implementation UIImage (color)


+ (UIImage *)createImageWithColor:(UIColor*) color withWidth:(CGFloat)width {
    
    CGRect rect = CGRectMake(0.0f, 0.0f, width, width);
    
    UIGraphicsBeginImageContext(rect.size);
    
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [color CGColor]);
    
    CGContextFillRect(context, rect);
    
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    
    return theImage;

//    CGRect rect = CGRectMake(0.0f, 0.0f, jisuan(1), jisuan(1));
//    UIGraphicsBeginImageContext(rect.size);
//    CGContextRef context = UIGraphicsGetCurrentContext();
//    CGContextSetFillColorWithColor(context, [color CGColor]);
//    CGContextFillRect(context, rect);
//    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
//    UIGraphicsEndImageContext();
//
//    return theImage;
    
}
@end
